from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Column, ForeignKey, String, Integer, DateTime, LargeBinary, create_engine
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


# 文件
class Files(Base):
    __tablename__ = 'files'
    id = Column(Integer, primary_key=True, autoincrement=True)
    file_name = Column(String(50))
    data = Column(LargeBinary(length=(2**26)-1))  # 文件最大16M
    create_time = Column(DateTime, nullable=True)
    suffix = Column(String(50))
    size = Column(Integer)
    type = Column(String(50))
    user_id = Column(Integer)
    token = Column(String(50))

    def __init__(self):
        pass

    def __repr__(self):
        return str(self.file_name)
